/*****  用于设置关于想定推演的所有问题 **********/

import commonConstants from "@/common/commonConstants";
import MonitorManager from "./monitor/MonitorManager";
import NoteTaker from "./noteTaker";
import DataHandler from "./scenmag/datahandler";
import DeduceEngineFactory from "./scenmag/deduceEngine";
import EffectManager from "./scenmag/effectManaager";
import ScenarioConfiguration from "./scenmag/ScenarioConfiguration";
import ScenarioManager from "./scenmag/ScenarioManager";
import DecisionMaker from "./scenmag/decisionMaker";

//是否在想定编辑状态
let editScenario = false;
let curViewer = undefined;
let scenarioConfiguration = undefined;
let scenarioManager = undefined;
let effectManager =undefined;
let monitorManager = undefined;
let deduceEngine = undefined;
let noteTaker = undefined;
let dataHandler = undefined;
let decisionMaker = undefined;




export default {
    //关于想定推演的一切类型都先初始化
    init(viewer,scenarioConfigurations){

        curViewer = viewer
        //默认配置
        scenarioConfiguration = new ScenarioConfiguration();
        //处理配置
        scenarioConfiguration.updataConfigurations(scenarioConfigurations);
        //初始化一些管理者
        //想定中有兵力、航迹、图层等不同的管理者
        scenarioManager= new ScenarioManager(curViewer,scenarioConfiguration);
        //所有的兵力效果或字幕等，都是由这里实现
        effectManager = new EffectManager(curViewer,scenarioConfiguration);
        //所有的监听者，都在这里管理
        monitorManager = new MonitorManager(curViewer,scenarioConfiguration.getConfigurationsByType(commonConstants.dataOperateType.Monitor));
        //数据处理可能要独立在想定管理之外，因为它要存储想定管理
        dataHandler = new DataHandler(scenarioConfiguration.getConfigurationsByType(commonConstants.dataOperateType.DataHandler));

        //想定要利用monitor 和 effect
        scenarioManager.setMonitorAndEffectManager(monitorManager,effectManager);

        decisionMaker = new DecisionMaker();

        //推演引擎的实现
        deduceEngine = DeduceEngineFactory.getEngine(curViewer,scenarioConfiguration);

        //记录员
        noteTaker = new NoteTaker(curViewer,scenarioConfiguration);
        return this;
    },
    getCUrViewer(){
        return curViewer;
    },
     /**
         *
         * @return {*|ScenarioManager}
         */
     getScenarioManager:function(){
        return scenarioManager;
    },
    getConfigValue(configKey){
        return scenarioConfiguration.getConfigurationsByKey(configKey).getValue();
    },
    /**
     * 是否在编辑状态
     */
    isEditScenario(){
        return editScenario;
    },
    deployScenario(curScenario){
        scenarioManager.setCurScenario(curScenario);
        scenarioManager.deployScenario();
        
        //改变一个值，使页面显示出对应的数据，就是当前想定信息和编辑中的信息
        editScenario = true;
    },
    delectScenarios(scenarios){
        scenarios.forEach(element => {
            scenarioManager.removeScenarioById(element.secnarioId)
        });
       
    },
    // /**
    //  *
    //  * @return {undefined|TroopManager}
    //  */
    // getTroopManager:function () {
    //     return scenarioManager.getCurScenario().getTroopManager();;
    // },
    /**
     *
     * @return {*|Scenario}
     */
    getCurScenario:function(){
        return scenarioManager.getCurScenario();
    },
    getDecisionMaker(){
        return decisionMaker;
    },
    // /**
    //  * @return {TrackManager}
    //  */
    // getTrackManager:function () {
    //     return scenarioManager.getCurScenario().getTrackManager();
    // },
    /**
     *
     * @return {*|MarkerManager}
     */
    getMarkerManager:function(){
      return scenarioManager.getCurScenario().getMarkerManager();
    },
    // /**
    //  *
    //  * @return {*|MonitorManager}
    //  */
    // getMonitorManager:function () {
    //     return monitorManager;
    // },
    /**
     *
     * @return 
     */
    getDeduceEngine:function () {
        return deduceEngine;
    },
    // /**
    //  *
    //  * @return {*|DataHandler}
    //  */
    getDataHandler:function () {
        return dataHandler;
    }
    // /**
    //  *
    //  * @return {*|LayerManager}
    //  */
    // getLayerManager:function(){
    //   return layerManager;
    // }
}